package cn.itsource.controller.app;

import cn.itsource.pojo.domain.Order;
import cn.itsource.pojo.ro.AddOrderRo;
import cn.itsource.result.JSONResult;
import cn.itsource.service.IOrderService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "订单表",description = "订单表")
@RestController
@RequestMapping("/app/order")
public class AppOrderController {

    @Autowired
    public IOrderService orderService;

    @GetMapping("/inprocess/customer")
    public JSONResult inprocess(){
        Order inprocess = orderService.inprocess();
        //如果查回来的东西为空
        if(inprocess == null){
           return JSONResult.error("未查询订单数据");
        }
        return JSONResult.success();
    }

    @PostMapping("/create")
    public JSONResult createOrder(@RequestBody @Valid AddOrderRo orderRo){
        return JSONResult.success(orderService.createOrder(orderRo));
    }
}
